package com.agentframework.core.provider;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author wangjun
 **/
@ConfigurationProperties(prefix = "llm")
public class LlmProperties {

    /**
     * 超时配置
     */
    private Timeout timeout = new Timeout(60);

    /**
     * 重试配置
     */
    private Retry retry = new Retry(3, 2);

    /**
     * 流处理配置
     */
    private Stream stream = new Stream(10);

    /**
     * 断路器配置
     */
    private CircuitBreaker circuitBreaker = new CircuitBreaker(true, 50, 30);

    /**
     * 超时配置记录
     * @param seconds 请求超时时间(秒)
     */
    public record Timeout(int seconds) {}

    /**
     * 重试配置记录
     * @param max 最大重试次数
     * @param initialDelaySeconds 初始重试延迟时间(秒)
     */
    public record Retry(int max, int initialDelaySeconds) {}

    /**
     * 流处理配置记录
     * @param bufferSize 流式响应缓冲区大小
     */
    public record Stream(int bufferSize) {}

    /**
     * 断路器配置记录
     * @param enabled 是否启用断路器
     * @param failureRate 触发断路器的失败率阈值(%)
     * @param waitDurationSeconds 断路器开启状态等待恢复时间(秒)
     */
    public record CircuitBreaker(boolean enabled, float failureRate, int waitDurationSeconds) {}

    // Getters and Setters for Spring Boot binding
    public Timeout getTimeout() {
        return timeout;
    }

    public void setTimeout(Timeout timeout) {
        this.timeout = timeout;
    }

    public Retry getRetry() {
        return retry;
    }

    public void setRetry(Retry retry) {
        this.retry = retry;
    }

    public Stream getStream() {
        return stream;
    }

    public void setStream(Stream stream) {
        this.stream = stream;
    }

    public CircuitBreaker getCircuitBreaker() {
        return circuitBreaker;
    }

    public void setCircuitBreaker(CircuitBreaker circuitBreaker) {
        this.circuitBreaker = circuitBreaker;
    }

}
